package com.durian.financial.api.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author zhouzhiyi
 * @Date 2022/6/26 10:11
 * @Description 分期期限枚举
 */
@Getter
public enum InstalmentEnum {

    ELEVEN(11,"11个月"),
    TWELVE(12,"12个月"),
    TWENTY_THREE(23,"23个月"),
    TWENTY_FOUR(24,"24个月"),
    INFINITE(-1,"无限期");

    @EnumValue
    @JsonValue
    private final Integer index;

    private final String value;

    InstalmentEnum(Integer index, String value) {
        this.index = index;
        this.value = value;
    }


    /**
     * 获取分期期限枚举Map
     *
     * @return Map<Integer,String>
     */
    public static Map<Integer,String> getInstalmentEnumMap(){

        Map<Integer, String> map = new HashMap<>();
        for (InstalmentEnum temp : EnumSet.allOf(InstalmentEnum.class)) {

            map.put(temp.index,temp.value);
        }

        return map;
    }
}
